package inet

import (
	"io"
	"net"

	"gitee.com/hasika/gotool/logx/stdlog"
)

type Conn interface {
	PublicConn
	ProtectedConn
}

type PublicConn interface {
	io.Reader
	GetFd() int
	GetConnectionId() int64
	GetReadCtx() *ReadCtx
	GetWriteCtx() IWriteCtx
	CloseConnectionAllCallback(reason string)
	InitConnection(self Conn, callback ConnectionCallback, nonblocking bool, writeCtx IWriteCtx, record bool)
	GetConnectionType() ConnectionType
	LowerWrite([]byte) error
	GetRemote() net.Addr
	SetSession(*Session)
	GetSession() *Session
}

type ProtectedConn interface {
	CloseConn() error
	InitFd()
}

//go:generate enumer -type=ConnectionType

type ConnectionType int

const (
	Source    ConnectionType = 0
	Tcp       ConnectionType = 1
	Kcp       ConnectionType = 2
	Udp       ConnectionType = 3
	Websocket ConnectionType = 4
)

const BufferMaxLen = 1024 * 4

var Log = stdlog.NewDefaultLog()
